<?php
namespace Act\Os;
class Setting extends Backend{
	public function doGet(){
		// print_r($_POST);exit;
		$this->display('index.php');
	}

	public function doPost(){
		foreach($_POST as $key=>$val){
			config($key,$val ? $val : null);
		}
		if(isset($_FILES['logo_file']) && $_FILES['logo_file']['error']==0){
			// move_file($_FILES['logo_file']['tmp_name'],APP_PATH.'assets/logs.jpg');
			$logo_path = storage('@'.$_FILES['logo_file']['tmp_name'],'',array('path'=>'images'));
			unlink($_FILES['logo_file']['tmp_name']);
			if($old_log_file = config('site_logo')){
				$url_info = parse_url($old_log_file);
				storage($url_info['path'],null);
			}
			config('site_logo',$logo_path);
		}
		$this->alert('success','设置成功');
		$this->display('index.php');
	}
}